<template>
    <div class="sidebar">
        <el-menu class="sidebar-el-menu" :default-active="onRoutes" :collapse="collapse" background-color="#301845"
            text-color="#fff" active-text-color="#20a0ff" unique-opened router>
            <template v-for="item in items">
                <template v-if="item.subs">
                    <el-submenu :index="item.index" :key="item.index">
                        <template slot="title">
                            <i :class="item.icon"></i><span slot="title">{{ item.title }}</span>
                        </template>
                        <el-menu-item v-for="(subItem,i) in item.subs" :key="i" :index="subItem.index">
                            {{ subItem.title }}
                        </el-menu-item>
                    </el-submenu>
                </template>
                <template v-else>
                    <el-menu-item :index="item.index" :key="item.index">
                        <i :class="item.icon"></i><span slot="title">{{ item.title }}</span>
                    </el-menu-item>
                </template>
            </template>
        </el-menu>
    </div>
</template>

<script>
    import bus from '../common/bus';
    export default {
        data() {
            return {
                collapse: false,
                items: [
                    {
                        icon: 'el-icon-setting',
                        index: '/api/introduce',
                        title: '平台介绍'
                    },
                    /*{
                        icon: 'el-icon-tickets',
                        index: 'table',
                        title: '账号信息',
                        subs: [
                            {
                                icon: 'el-icon-tickets',
                                index: '/account',
                                title: '我的资质'
                            }, 
                            {
                                icon: 'el-icon-tickets',
                                index: '/team',
                                title: '团队成员'
                            }
                        ]
                    },
                    {
                        icon: 'el-icon-menu',
                        index: 'product',
                        title: '产品管理',
                        subs: [
                            {
                                icon: 'el-icon-tickets',
                                index: '/product',
                                title: '产品管理'
                            }, 
                            {
                                icon: 'el-icon-tickets',
                                index: '/selectRequest',
                                title: '申请查询'
                            }
                        ]
                    },
                    {
                        icon: 'el-icon-date',
                        index: '3',
                        title: '测试联调',
                        subs: [
                            {
                                index: '/testCase',
                                title: '测试用例'
                            }
                        ]
                    },
                    {
                        icon: 'el-icon-star-on',
                        index: 'charts',
                        title: 'schart图表'
                    },
                    {
                        icon: 'el-icon-rank',
                        index: 'drag',
                        title: '拖拽列表'
                    },
                    {
                        icon: 'el-icon-warning',
                        index: 'permission',
                        title: '权限测试'
                    },
                    {
                        icon: 'el-icon-error',
                        index: '404',
                        title: '404页面'
                    }*/
                ]
            }
        },
        computed:{
            onRoutes(){
                return this.$route.path
            }
        },
        created(){

        }
    }
</script>

<style lang="less">
    .sidebar{
        display: block;
        position: absolute;
        left: 0;
        top: 60px;
        bottom:0;
        overflow-y: scroll;
        border-right: 1px solid #b4b4b4;
        .el-menu-item.is-active {
    background-color: #20a8d8 !important;
    color: #fff !important;
}
    }
    .sidebar::-webkit-scrollbar{
        width: 0;
    }
    .sidebar-el-menu:not(.el-menu--collapse){
        width: 250px;
    }
    .sidebar > ul {
        height:100%;
    }
</style>
